<template>
	<view class="build-wrap">
		<view class="build-head u-p-l-30 u-p-r-30 u-p-t-20 u-p-b-20 u-font-36">
			{{buildName}}
		</view>
		<view @click="strBtn(item)" v-for="(item,index) in buildList" :key="index" class="build-list u-p-l-30 u-p-r-30 u-p-t-20 u-p-b-20 u-font-32">
			{{buildName}}/{{item.roomCode}}
		</view>
		<u-modal @confirm='queryBtn' :zoom='false' v-model="modelShow" :show-title='false' :show-cancel-button='true'
		 confirm-color="#F9A832">
			<view class="u-p-t-30 u-p-l-50  u-font-28">
				{{content}}
			</view>
			<view class="u-p-t-20 u-p-b-30 u-p-l-50  u-font-28">
				确认信息是否正确？
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buildName: null,
				buildList: [],
				modelShow: false,
				content: null,
				item: null,
			}
		},
		onShow() {
			this.getBuild()
			this.buildName = this.$Route.query.name
		},
		methods: {
			// 获取期
			async getBuild() {
				let res = await this.$request.api.home({
					pro_id: this.$Route.query.id,
					build_id: this.$Route.query.buildId,
					unit_id: this.$Route.query.unit_id
				})
				this.buildList = res.data.data
			},
			strBtn(val) {
				this.item = val;
				this.content = this.buildName + '/' + val.roomCode
				this.modelShow = true
			},
			async queryBtn() {
				let res = await this.$request.api.queryHome({
					open_id: uni.getStorageSync('openId'),
					mobile: uni.getStorageSync('phone'),
					room_id: this.item.roomId
				})
				// 0 手机号不一致  1 通过   2 已提交房本 等待审核  3后台认证失败  4不通过
				if (res.data.data == 0) {
					this.$Router.push({
						path: '/pages/uploadRoon/uploadRoon',
						query: {
							room_id: this.item.roomId,
							type:1
						}
					})
				} else if (res.data.data == 1) {
					this.$Router.push({
						path: '/pages/examine/examine',
						query: {
							examineNum: 1
						}
					})
				} else if (res.data.data == 2) {
					this.$Router.push({
						path: '/pages/examine/examine',
						query: {
							examineNum: 2
						}
					})
				} else if (res.data.data == 3) {
					this.$Router.push({
						path: '/pages/examine/examine',
						query: {
							examineNum: 3,
							room_id: this.item.roomId
						}
					})
				}
			}
		}
	}
</script>

<style lang='scss'>
	.build-wrap {
		width: 100vw;
		height: 100vh;

		.build-head {
			border-bottom: 10px solid #f4f4f4;
			color: #333;
		}

		.build-list {
			border-bottom: 1px solid #f4f4f4;
			color: #333;
		}
	}
</style>
